﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AirlineProject.Models;
namespace AirlineProject.Areas.admin.Controllers
{
    public class LoginController : Controller
    {
        //
        // GET: /admin/Login/

        public ActionResult Index()
        {
            return View();
        }
        
        public ActionResult handlogin(string user_name, string password)
        {
            
            User tk = new User();         
            AccountModels tkm = new AccountModels(); 
            tk = tkm.LoginAdmin(user_name, password);
            if (tk == null)
            {
                ViewData["message"] = "Invalid account";
                return View("index");
            }
            else
            {
                if (tk.rights == 1)
                {
                    ViewData["message"] = "Invalid account";
                    return View("index");
                }
                else
                {
                    Session["account"] = tk;
                    return RedirectToAction("Index", "templateadmin");
                }
            }           
        }
        
    }
}
